package com.CTAtracker.android.Activities;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.CTAtracker.android.R;
import com.CTAtracker.android.Fragments.SeveralStationFragment;

public class SeveralStationActivity extends Activity{
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		int parentId;
		String nameStation;
		
		super.onCreate(savedInstanceState);
		// set the current layout
		setContentView(R.layout.several_stations_activity);
		// set the current Fragment
		parentId = getIntent().getExtras().getInt("parentId");
		nameStation = getIntent().getExtras().getString("nameStation");
		
		// Inflate Menu
        ActionBar actionbar = getActionBar();
        actionbar.setDisplayShowTitleEnabled(false);
        actionbar.setDisplayShowCustomEnabled(true);
        actionbar.setDisplayShowHomeEnabled(false);
        actionbar.setCustomView(R.layout.actionbar_back);

        ImageView back_button = (ImageView) findViewById(R.id.back_button);
        back_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
		
		SeveralStationFragment severalStationFragment = new SeveralStationFragment();
		severalStationFragment.setName(nameStation); 
		severalStationFragment.setParentId(parentId);
		this.replaceContent(severalStationFragment);
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	/**
	 * This method replace the current fragment
	 * @param frag the new fragment
	 */
	public void replaceContent(Fragment frag) {
		getFragmentManager()
		.beginTransaction()
		.replace(R.id.severalStationActivity, frag)
		.commit();
	}
}
